`
https://leetcode.cn/problems/set-mismatch/
`

/**
 * @param {number[]} nums
 * @return {number[]}
 */
var findErrorNums = function (nums) {
  const n = nums.length
  let rep = 0

  for (let i = 0; i < n; i++) {
    const idx = Math.abs(nums[i]) - 1
    if (nums[idx] < 0) {
      rep = Math.abs(nums[i])
      continue
    }
    nums[idx] *= -1
  }

  let miss = 0

  for (let i = 0; i < n; i++) {
    if (nums[i] > 0) {
      miss = i + 1
    }
  }

  return [rep, miss]
};